<template>
  <div></div>
</template>

<script>
import { getToken } from 'api/authorize'
// import axios from 'axios'
export default {
  created() {
    let self = this
    getToken().then(res => {
      // 获取未登录Token成功后存入缓存和store,然后跳转回原地址
      this.$store.dispatch('user/setToken', res.Data)
      localStorage.setItem('Token', res.Data.Token)
      localStorage.setItem('RefreshToken', res.Data.RefreshToken)
      this.$router.replace({
        path: this.$route.query.redirect
      })
    })
    //   axios
    //     .post('https://shopnew.test.hsy884.com/api/Authorize/Token', {})
    //     .then(res => {
    //       // 获取未登录Token成功后存入缓存和store,然后跳转回原地址
    //       self.$store.dispatch('user/setToken', res.Data)
    //       localStorage.setItem('Token', res.Data.Token)
    //       localStorage.setItem('RefreshToken', res.Data.RefreshToken)
    //       self.$router.replace({
    //         path: self.$route.query.redirect
    //       })
    //     })
    //     .catch(function(error) {
    //       console.log(error)
    //     })
  }
}
</script>
